home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / Goodies / SYSTEM~1 / README.TXT next >
Text File  |  1997-06-13  |  3KB  |  54 lines

  1. System Color Control Sample - created by Randy Russell - June 1997
  2. ActiveX Control created with Microsoft Visual Basic 5.0
  3.  
  4. This sample presents a scrollable ListView type collection of the current
  5. Windows System Colors. The sample could be easily modified to display
  6. icons, bitmaps or whatever you have in mind. It currently displays a 3D
  7. box filled with with the system color next to each system color name. It
  8. is mostly hard coded, using only a scroll bar, so it is very flexible and
  9. lightweight.
  10.  
  11. Open the project group SysColors.vbg to review the entire sample.
  12. If you open the SysColorSample.vbp project you will receive a load error
  13. because the SysColorControl is not in that project. You can open the
  14. SysColorControl.vbp project to review or compile the control separately.
  15. If you remove the SysColors control from the SysColorSample project then
  16. you will be able to work with the class/form version alone.
  17.  
  18. I included a form version of the control that can be displayed independent
  19. of a container, i.e., popup. The form is wrapped by the SysColors class that
  20. could be added to a dll component for reusability. Click the Popup button
  21. for a demonstration of the popup form. The control could also be used as
  22. a popup by setting its visible property accordingly, however, it will be
  23. confined to its container.
  24.  
  25. The control sets two read-only properties when a selection is made:
  26. SelectedColor - Actual System Color value - Long
  27. SelectedColorName - System Color name - String
  28. If you right-click the control, the SelectedColorName property is set 
  29. to "". This could be changed to leave the current color selected so you 
  30. would not have to watch for the "" condition by changing the line under
  31. "If button = 2 Then" in the MouseDown procedure to Exit Sub.
  32.  
  33. I added a ClickType property to the control so you can choose whether a
  34. single or a double click is required to set the selection. This property can also
  35. be added to the popup form version but I did not implement it here. This
  36. property is demonstrated by the "Set to Single Click" button.
  37.  
  38. The control will display a default color which is highlighted. You can 
  39. select which color will be displayed as the default by setting the 
  40. DefaultColor property.
  41.  
  42. As a fun project, you could convert the sample into a drop-down system
  43. color control. It would be fairly straightforward as long as you understand
  44. the sample as is. You could change the initial size to display only one row,
  45. add a small button with a down arrow that, when clicked, refreshed the form
  46. to its full size (dropped), and then have it display the selected color as the
  47. top row and return it to the one row size when the user makes a selection.
  48. Voila - a dropdown, scrollable list view type, system color control.
  49.  
  50. I hope you like the sample and Keep on Codin'.
  51.  
  52. Randy Russell
  53. 73774,1126@compuserve.com
  54.